import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-01-29
 * Time:14:45
 */
public class Main {
//    给定一个长度为n的字符串，字符串中只包含大小写字母。请你返回该字符串拥有那些字符。
//    并将它们按照出现的先后顺序拼接成一个新的字符串。
    public String toString(char[] arr) {
        StringBuilder stringBuilder = new StringBuilder("");
        for (int i = 0; i < arr.length; i++) {
            stringBuilder.append(arr[i]);
        }
        return stringBuilder.toString();
    }


    public String setstring (String str) {
        // write code here
        //新建一个字符数组，把字符串的字符存进去（不重复）
        int n = str.length();
        char[] array = new char[n];
        int len = 0;  //array的有效长度
        for(int i = 0;i < n;i++) {
            int flag = 1;
            //遍历array
            for(int j = 0;j <= len;j++) {
                //找到重复的字符
                if(array[j] == str.charAt(i)) {
                    flag = 0;
                    break;
                }

            }
            //没有重复字符，那就把第i个放进array
            if(flag == 1) {
                array[len] = str.charAt(i);
                ++len;
            }
        }
        char[] array1 = new char[len];
        for (int i = 0; i < len; i++) {
            array1[i] = array[i];
        }
        String s = toString(array1);
        System.out.println(s);
        return s;
    }


    public static void main(String[] args) {
        new Main().setstring("abcdeAAA");
    }

///////////////////////////////////////////////

    public void merge(int A[], int m, int B[], int n) {
        int[] C = new int[m+n];
        int a = 0,b=0;  //双指针
        int c = 0;
        while(a < m && b < n) {
            if(A[a] <= B[b]) {
                C[c++] = A[a++];
            } else {
                C[c++] = B[b++];
            }
        }

        //检查剩余元素
        if(a == m) {
            while(b < n) {
                C[c++] = B[b++];
            }
        } else {
            while (a < m) {
                C[c++] = A[a++];
            }
        }

        for(int i = 0;i < m+n;i++) {
            A[i] = C[i];
        }

    }




}

